<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/Validform_css.css" />
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/Validform_v5.3.2.js"></script>
<!--强度-->
<script type="text/javascript" src="js/passwordStrength-min.js"></script> 
<script type="text/javascript" src="js/verification.js"></script>
<title>表单验证</title>
<script type="text/javascript">
$(function(){
	
	$(".registerform").Validform({
		tiptype:2,
		datatype:{//传入自定义datatype类型【方式二】;
			"idcard":function(gets,obj,curform,datatype){
				//该方法由佚名网友提供;
			
				var Wi = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 ];// 加权因子;
				var ValideCode = [ 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2 ];// 身份证验证位值，10代表X;
			
				if (gets.length == 15) {   
					return isValidityBrithBy15IdCard(gets);   
				}else if (gets.length == 18){   
					var a_idCard = gets.split("");// 得到身份证数组   
					if (isValidityBrithBy18IdCard(gets)&&isTrueValidateCodeBy18IdCard(a_idCard)) {   
						return true;   
					}   
					return false;
				}
				return false;
				
				function isTrueValidateCodeBy18IdCard(a_idCard) {   
					var sum = 0; // 声明加权求和变量   
					if (a_idCard[17].toLowerCase() == 'x') {   
						a_idCard[17] = 10;// 将最后位为x的验证码替换为10方便后续操作   
					}   
					for ( var i = 0; i < 17; i++) {   
						sum += Wi[i] * a_idCard[i];// 加权求和   
					}   
					valCodePosition = sum % 11;// 得到验证码所位置   
					if (a_idCard[17] == ValideCode[valCodePosition]) {   
						return true;   
					}
					return false;   
				}
				
				function isValidityBrithBy18IdCard(idCard18){   
					var year = idCard18.substring(6,10);   
					var month = idCard18.substring(10,12);   
					var day = idCard18.substring(12,14);   
					var temp_date = new Date(year,parseFloat(month)-1,parseFloat(day));   
					// 这里用getFullYear()获取年份，避免千年虫问题   
					if(temp_date.getFullYear()!=parseFloat(year) || temp_date.getMonth()!=parseFloat(month)-1 || temp_date.getDate()!=parseFloat(day)){   
						return false;   
					}
					return true;   
				}
				
				function isValidityBrithBy15IdCard(idCard15){   
					var year =  idCard15.substring(6,8);   
					var month = idCard15.substring(8,10);   
					var day = idCard15.substring(10,12);
					var temp_date = new Date(year,parseFloat(month)-1,parseFloat(day));   
					// 对于老身份证中的你年龄则不需考虑千年虫问题而使用getYear()方法   
					if(temp_date.getYear()!=parseFloat(year) || temp_date.getMonth()!=parseFloat(month)-1 || temp_date.getDate()!=parseFloat(day)){   
						return false;   
					}
					return true;
				}
				
			}
			
		}
	});
})
</script>
</head>
<body>
	<div id="forms" class="mt10">
		<div class="box">
			<div class="box_border" style="width:50%; margin:auto;">
				<form action="" class="jqtransform">
                    <table class="form_table pt15 pb15" width="100%" border="0"
                        cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="td_right" width="90px">用户名称：</td>
                            <td>
                            	<input type="text" value="" name="name" class="inputxt Validform_error" 
                        			datatype="s6-18" errormsg="昵称至少6个字符,最多18个字符！" nullmsg="请填写信息！">                         
                            </td>
                            <td>
                            	<div class="Validform_checktip">请输入用户名</div>
                           </td>
                        </tr>
                        <tr>
		                    <td style="width: 90px;">您的账号：</td>
		                    <td><input name="mobile" class="inputxt" type="text" value="" 
		                    errormsg="账号可以是手机或邮箱地址！" datatype="m|e" nullmsg="请填写信息！"></td>
		                    <td><div class="Validform_checktip">请填写信息</div></td>
		                </tr>
                        <tr>
                            <td class="td_right" >密码：</td>
                            <td><input type="password" value=""
                                    name="password" class="inputxt" plugin="passwordStrength"
                                    datatype="*6-18" nullmsg="请输入密码！" errormsg="密码至少6个字符,最多18个字符！" />
                                <div class="passwordStrength">
                                    密码强度： <span>弱</span><span>中</span><span class="last">强</span>
                                </div>
                            </td>
                            <td>
                            	<div class="Validform_checktip">请输入新密码</div>                                
                            </td>
                        </tr>
                        <tr>
                            <td class="td_right" >确认密码：</td>
                            <td><input type="password" value="" name="repassword"
                                class="inputxt" nullmsg="请再一次输入密码！" recheck="password" datatype="*6-18"
                                errormsg="两次输入的密码不一致！" /></td>
                            <td>
                                <div class="Validform_checktip">请输入确认密码</div>
                            </td>
                        </tr>
                        
                        <tr>
                            <td>移动电话：</td>
                            <td><input type="text" value="" name="tel" class="inputxt" datatype="m" errormsg="请输入您的手机号码！"></td>
                            <td>
                                <div class="Validform_checktip">请输入确认移动电话</div>
                            </td>
                        </tr>
                        
                        <tr>
                            <td>性别：</td>
                            <td>
                            	<input type="radio" value="1" name="gender" id="male" class="pr1" datatype="*" errormsg="请选择性别！">
                                <label for="male">男</label> 
                                <input type="radio" value="2" name="gender" id="female" class="pr1">
                                <label for="female">女</label>
                            </td>
                            <td>
                            	<div class="Validform_checktip">请选择性别</div>
                            </td>
                        </tr>
                        
                        <tr>
                            <td>身份证：</td>
                            <td>
                                <input name="name" class="inputxt" type="text" value="" errormsg="您填写的身份证号码不对！" datatype="idcard" nullmsg="请填写身份证号码！">
                            </td>
                            <td><div class="Validform_checktip">请填写身份证号码</div></td>
                        </tr>
                        <tr>
                            <td>身份证15/18：</td>
                            <td>
                                <input name="name" class="inputxt" type="text" value="" 
                                errormsg="您填写的身份证号码不对！" datatype="idcard" nullmsg="请填写身份证号码！">
                            </td>
                            <td><div class="Validform_checktip">请填写身份证号码</div></td>
                        </tr>
                        
                        
                        <tr>
                            <td>备注：</td>
                            <td colspan="3">
                                <textarea tip="请在这里输入您的意见。" altercss="gray" class="gray" name="msg" value="">请在这里输入您的意见。</textarea>
                            </td>
                        </tr>
                        
                        <tr>
                            <td colspan="3">
                            	<input type="submit" name="button" class="btn btn82 btn_save2" value="保存" style="position: relative;margin-left:200px;" /> 
                                <input type="reset" name="button" class="btn btn82 btn_res" value="重置" style="position: relative;margin-left:50px;" />
                            </td>
                        </tr>
                    </table>
				</form>
			</div>
		</div>
	</div>
</body>
</html>
